<?php

namespace app\common\model\factory;

use think\Model;


class Goods extends Model
{


    // 表名
    protected $name = 'factory_sales_goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'needtime_text'
    ];

    public function goods_status(){
        return array(
          1=>'待处理',
          2=>'待发货',
          3=>'发货中',
          4=>'已到货',
          5=>'中止',
        );
    }
    public function goods_type(){
        return array(
            1=>'正常销售',
            2=>'库存填补',
        );
    }




    public function getNeedtimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['needtime']) ? $data['needtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setNeedtimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

}
